#pragma once

#include <list>
#include <vector>

#include "ast.h"
#include "location.h"
#include "pass.h"
#include "token.h"

class Lexer : public Pass {
    std::string text;
    std::string::const_iterator it;
    Location loc;

    bool Empty() const;
    int Peek() const;
    void Prev();
    int Next();
    bool Try(char c);
    bool Expect(char c);

    void SkipSpace();
    void SkipInlineComment();
    void SkipBlockComment();

    Token::BaseToken* HandleNumber(Location beginLoc);

    Token::BaseToken* HandleIdentifier(Location beginLoc);

    Token::BaseToken* HandleString(Location beginLoc);

  public:
    Token::BaseToken* NextToken();
    std::list<Token::BaseToken*>* Scan();

    void* Run(void* input) override;
};
